class ItemCategoriesController < ApplicationController
  def index
    @item_categories = ItemCategory.all
  end
  
  def show
    @item_category = ItemCategory.find(params[:id])
  end
  
  def new
    @item_category = ItemCategory.new
  end
  
  def create
    @item_category = ItemCategory.new(params[:item_category])
    if @item_category.save
      flash[:notice] = "Successfully created item category."
      redirect_to @item_category
    else
      render 'new'
    end
  end
  
  def edit
    @item_category = ItemCategory.find(params[:id])
  end
  
  def update
    @item_category = ItemCategory.find(params[:id])
    if @item_category.update_attributes(params[:item_category])
      flash[:notice] = "Successfully updated item category."
      redirect_to @item_category
    else
      render 'edit'
    end
  end
  
  def destroy
    @item_category = ItemCategory.find(params[:id])
    @item_category.destroy
    flash[:notice] = "Successfully destroyed item category."
    redirect_to item_categories_url
  end
end
